//
//  ManagerUtil.m
//  Venue_reservation
//
//  Created by 蔡舟 on 15/10/15.
//  Copyright (c) 2015年 com.zkingsoft. All rights reserved.
//

#import "ManagerUtil.h"
#import "AppDelegate.h"

@implementation ManagerUtil


+(void)setLoginUser:(User *)user{
    NSData *userData = [NSKeyedArchiver archivedDataWithRootObject:user];
    [[NSUserDefaults standardUserDefaults] setObject:userData forKey:@"maxinitInSaveUserInfo"];
}

+(User *)getLoginUser{
    NSData *userData = [[NSUserDefaults standardUserDefaults] objectForKey:@"maxinitInSaveUserInfo"];
    User *user =[NSKeyedUnarchiver unarchiveObjectWithData:userData] ;
    return user ;
}


#pragma mark 删除登陆用户
+ (void)deleteLoginUser{
    [[NSUserDefaults standardUserDefaults] setObject:nil forKey:@"maxinitInSaveUserInfo"];
    [[NSUserDefaults standardUserDefaults] synchronize];
}

+(void)needRefreshViewController{
    needRefresh = YES;
}

+(BOOL)isNeedRefreshViewController{
    return needRefresh;
}

+(void)noNeedRefreshViewController{
    needRefresh = NO;
}

#pragma mark 判断是否登录
+(BOOL)isLogin{
    if ([ManagerUtil getLoginUser] !=nil) {
        return true;
    }else{
        return  false;
    }
}

@end
